using System;
using StructureMap;
using Impact.Infrastructure.Configuration;

namespace Impact.Web.Foundation
{
    /// <summary>
    /// Base class for controls used to display dynamic pages
    /// </summary>
    public abstract class DynamicPageControlBase : Impact.Web.Foundation.UserControlBase
    {

        /// <summary>
        /// perform load time tasks
        /// </summary>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            IConfigProvider config = ObjectFactory.GetInstance<IConfigProvider>();
            if (!string.IsNullOrEmpty(config.Settings.PageTitlePrefix))
            {
                Page.Title = string.Format("{0}: {1}", config.Settings.PageTitlePrefix, PageTitle);
            }
            else
            {
                Page.Title = PageTitle;
            }

        }

        /// <summary>
        /// when overridden, returns the title of the page
        /// </summary>
        protected abstract string PageTitle
        {
            get;
        }

    }
}
